<{extend name="public/base"}>
<{block name="content"}>


<div class="box">
    <div class="box-header">
        <h3 class="box-title"><{$title}></h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">

        <table id="example1" class="table table-bordered table-striped">
            <thead>
            <tr>
                <th>配置项</th>
                <th>配置名称</th>
                <th>配置值</th>
                <th>说明</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <{volist name="model" id="item"}>
            <tr>
                <td><{$item.ckey}></td>
                <td><{$item.label}></td>
                <td><input type="text" value="<{$item.cvalue}>"  id="<{$item.ckey}>" class="form-control"/></td>
                <td><{$item.placeholder}></td>
                <td>
                    <a href="javascript:;" class="btn btn-primary btn-sm update" data-ckey="<{$item.ckey}>">更新值</a>
                    <a href="javascript:;" class="btn btn-danger btn-sm delete" data-ckey="<{$item.ckey}>">删除</a>
                </td>
            </tr>
            <{/volist}>

            </tbody>
            <tfoot>
            <tr>
                <th>配置项</th>
                <th>配置名称</th>
                <th>配置值</th>
                <th>说明</th>
                <th>操作</th>
            </tr>
            </tfoot>
        </table>

    </div>
    <!-- /.box-body -->
</div>

<{/block}>
<{block name="foot_script"}>
    <script type="text/javascript">
        $(".update").click(function(){
            var ckey = $(this).data('ckey');
            var cvalue = $("#"+ckey).val();
            console.log({ckey:ckey,cvalue:cvalue});
            $.post('<?php echo url("admin/config/update"); ?>',{ckey:ckey,cvalue:cvalue},function(data){
                alert(data.msg);
                console.log(data);
            });
        });
        $('.delete').click(function(){
            var ckey = $(this).data('ckey');
            $.post('<?php echo url("admin/config/delete"); ?>',{ckey:ckey},function(data){
                alert(data.msg);
                if(data.code == 1){
                    window.location.reload();
                }
            });
        });
    </script>
<{/block}>